<?php
session_start();
/**
Eventos de FrmTypes
**/

//MApache
require("../../../weblinx/weblinx.php");
//-------

//----Formularios requeridos----

//------------------------------

//----Clases requeridas---------
require("../../Classes/Setter.php");
require("../../Classes/Sentinel.php");
require("../../Classes/Admin/Type.php");
require("../../Forms/Admin/FrmTableTypes.php");

//-----------------------------

//---Events--------------------
if (isset($_GET['AceptarTipo'])){
	$validator=new ValidatorPHP("","","okValidatorFrmTypes","aceptar",array("onclick"=>"GETMethodSend('okValidatorFrmTypes','tableTypes','../../Events/Admin/EventsFrmTypes.php')"),"cancelValidatorFrmTypes","cancelar",array("onclick"=>"GETMethodSend('cancelValidatorFrmTypes','tableTypes','../../Events/Admin/EventsFrmTypes.php')"));
	$r=0;
	while($r==0){
		if($validator->noEmpty($_GET['nombreTipo'],"El campo Nombre no puede estar vacío", "../../../weblinx/Images/warning.png")==false){
			$r++;
			break;
		}
		if($r==0){
			//Verificar que el nombre no esté ya en la bd	
			$sentinel=new Sentinel();
			$idT=$sentinel->idVerify($_GET['nombreTipo'],"tiposInmueble", "nombre");
			if($idT==false){
					$setter=new Setter("../../Config");
					
					$type=new Type();
					$type->setNombre($_GET['nombreTipo']);
					$type->guardar();
					
					$messageBox=new MessageBox($image="../../../weblinx/Images/warning.png",$messageText="<b>Se ha registrado un nuevo tipo de inmueble con éxito </b>",$okButtonName="okValidatorFrmTypes",$okButtonValue="ok",$okButtonEvents=array("onclick"=>"GETMethodSend('okValidatorFrmTypes','tableTypes','../../Events/Admin/EventsFrmTypes.php')"),$cancelButtonName="cancelValidatorFrmTypes",$cancelButtonValue="cancel",$cancelButtonEvents=array("onclick"=>"GETMethodSend('cancelValidatorFrmTypes','tableTypes','../../Events/Admin/EventsFrmTypes.php')"));
					$messageBox->setVisible("visible");
					$messageBox->show();
				
					$frmTableTypes=new FrmTableTypes();
					$frmTableTypes->show();
					break;
			}
			else{
				$messageBox=new MessageBox($image="../../../weblinx/Images/warning.png",$messageText="<blink><b>Error al tratar de registrar el tipo de inmueble: El nombre ya ha sido registrada antes!! </b></blink>",$okButtonName="okValidatorFrmTypes",$okButtonValue="ok",$okButtonEvents=array("onclick"=>"GETMethodSend('okValidatorFrmTypes','tableTypes','../../Events/Admin/EventsFrmTypes.php')"),$cancelButtonName="cancelValidatorFrmTypes",$cancelButtonValue="cancel",$cancelButtonEvents=array("onclick"=>"GETMethodSend('cancelValidatorFrmTypes','tableTypes','../../Events/Admin/EventsFrmTypes.php')"));
				$messageBox->setVisible("visible");
				$messageBox->show();
				break;
			}
		}
	}	
}
else if(isset($_GET['okValidatorFrmTypes'])){
		$frmTableTypes=new FrmTableTypes();
		$frmTableTypes->show();
}
else if(isset($_GET['cancelValidatorFrmZones'])){
		$frmTableTypes=new FrmTableTypes();
		$frmTableTypes->show();
}
//-------------

//---Fin Events----------------
?>
